package OOM;

import java.util.concurrent.*;

/**
 * -Xss1M 设置大一点 最小栈大小  容易占满
 * -Xss 线程栈的大小参数
 *
 * @author caihe
 * @date 2021/11/1 14:08
 */
public class ThreadOOM {

    public static void main(String[] args) {
//        ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(Integer.MAX_VALUE,
//                Integer.MAX_VALUE, 10, TimeUnit.SECONDS, new SynchronousQueue());
//
//        try {
//            for (int i = 0; i < Integer.MAX_VALUE; i++) {
//                threadPoolExecutor.execute(()->{
//                    try {
//                        Thread.sleep(100);
//                    } catch (InterruptedException e) {
//                        e.printStackTrace();
//                    }
//                });
//            }
//        } catch (Throwable e) {
//            System.out.println(threadPoolExecutor.getActiveCount());
//            e.printStackTrace();
//        }
        while(true){
            new Thread(() -> {
                try {
                    Thread.sleep(Integer.MAX_VALUE);
                } catch(InterruptedException e) { }
            }).start();
        }
    }

}
